package com.baijiayun.liveuibase.widgets.popupwindow;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.baijiayun.liveuibase.R;
import com.baijiayun.liveuibase.utils.DisplayUtils;
import com.baijiayun.liveuibase.utils.ThemeDataUtil;
import com.baijiayun.liveuibase.utils.drawable.DrawableBuilder;

public class ErrorDesPopupWindow extends BaseAutoArrangePopupWindow {
    TextView tvErrorMsg;
    View errorContainer;

    public ErrorDesPopupWindow(Context context) {
        super(context);

        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        View contentView = LayoutInflater.from(context).inflate(R.layout.uibase_file_translate_error_des_pop_window, linearLayout);
        tvErrorMsg = contentView.findViewById(R.id.base_file_translate_error_msg);
        errorContainer = contentView.findViewById(R.id.base_file_translate_error_container);
        contentView.findViewById(R.id.base_file_translate_error_container).setBackground(new DrawableBuilder()
                .solidColor(ThemeDataUtil.getColorFromThemeConfigByAttrId(context, R.attr.base_theme_brand_container_color))
                .cornerRadius(DisplayUtils.dip2px(context,4))
                .build());
        setDirectionMode(HORIZONTAL);

        createView(linearLayout, false);
        setFocusable(true);
    }

    @Override
    protected void initViewDataHashMap() {
        // do nothing
    }

    @Override
    public void show(View anchor) {
        showWithViewOfDirection(anchor, LEFT_TOP);
    }

    public void updateErrorMsg(String errorMsg) {
        tvErrorMsg.setText(errorMsg);
    }
}
